ESO-447: Expand Vault e2e for TLS trustedCABundle and ExternalSecret templating - #169
ESO-447: Expand Vault e2e for TLS trustedCABundle and ExternalSecret templating#169bharath-b-rh wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@bharath-b-rh: This pull request references ESO-447 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughThe E2E suite installs cert-manager through OLM, provisions TLS-enabled Vault resources, tests trusted CA recovery, validates merged Kubernetes and Vault registry credentials, and updates supporting utilities and documentation. ChangesVault E2E coverage
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant E2ETests
participant CertManager
participant Kubernetes
participant Vault
participant ExternalSecretsOperator
E2ETests->>CertManager: create Issuer and Certificate resources
CertManager->>Kubernetes: create CA and TLS Secrets
E2ETests->>Vault: deploy and initialize HTTPS Vault
E2ETests->>ExternalSecretsOperator: configure trustedCABundle and SecretStores
ExternalSecretsOperator->>Vault: read and write secret data
ExternalSecretsOperator->>Kubernetes: reconcile merged ExternalSecret
E2ETests->>Kubernetes: verify readiness and registry entries
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 3 warnings)
✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)Error: build linters: unable to load custom analyzer "kubeapilinter": bin/kube-api-linter.so, plugin: not implemented Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bharath-b-rh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (3)
test/e2e/cert_manager_helpers_test.go (1)
109-141: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
k8serrors.IsNotFoundover string matching.
strings.Contains(err.Error(), "not found")is fragile compared to the structuredk8serrors.IsNotFound(err)check used elsewhere in this PR (e.g.ensureVaultNamespace). Text matching can silently misclassify errors if the message format changes.♻️ Proposed fix
pods, err := clientset.CoreV1().Pods(certManagerOperandNamespace).List(ctx, metav1.ListOptions{}) if err != nil { - if strings.Contains(err.Error(), "not found") { + if k8serrors.IsNotFound(err) { return false, nil } return false, err }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/cert_manager_helpers_test.go` around lines 109 - 141, Update waitForCertManagerOperandPods to use the Kubernetes structured not-found check k8serrors.IsNotFound(err) instead of matching "not found" in err.Error(), while preserving the existing retry behavior for not-found errors and propagation of all other errors.test/e2e/e2e_test.go (1)
2759-2816: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winWrap ConfigMap update with
retry.RetryOnConflict.
createVaultCAConfigMapandcreateSampleCAConfigMapdo a plain Get→mutate.Data→Update without conflict retry. The referenced ConfigMap (vaultCAConfigMapName) is the same object the operator's watch-label reconciler patches once it's referenced bytrustedCABundle(pertrusted_ca_bundle_test.go's watch-label restoration test), so a concurrent operator patch between our Get and Update can produce a conflict error that isn't retried, unlike the establishedretry.RetryOnConflictpattern used insetTrustedCABundle/clearTrustedCABundlein this same file.♻️ Proposed fix (apply the same pattern to both functions)
- existing, err := clientset.CoreV1().ConfigMaps(operandNamespace).Get(ctx, vaultCAConfigMapName, metav1.GetOptions{}) - if k8serrors.IsNotFound(err) { - _, err = clientset.CoreV1().ConfigMaps(operandNamespace).Create(ctx, cm, metav1.CreateOptions{}) - return err - } - if err != nil { - return err - } - existing.Data = cm.Data - _, err = clientset.CoreV1().ConfigMaps(operandNamespace).Update(ctx, existing, metav1.UpdateOptions{}) - return err + return retry.RetryOnConflict(retry.DefaultRetry, func() error { + existing, err := clientset.CoreV1().ConfigMaps(operandNamespace).Get(ctx, vaultCAConfigMapName, metav1.GetOptions{}) + if k8serrors.IsNotFound(err) { + _, err = clientset.CoreV1().ConfigMaps(operandNamespace).Create(ctx, cm, metav1.CreateOptions{}) + return err + } + if err != nil { + return err + } + existing.Data = cm.Data + _, err = clientset.CoreV1().ConfigMaps(operandNamespace).Update(ctx, existing, metav1.UpdateOptions{}) + return err + })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e_test.go` around lines 2759 - 2816, Wrap the existing ConfigMap Get, Data mutation, and Update flow in both createVaultCAConfigMap and createSampleCAConfigMap with retry.RetryOnConflict, re-fetching the ConfigMap on each retry and returning non-conflict errors immediately. Preserve the existing create-on-NotFound behavior and ensure the retry callback propagates the final update error.test/e2e/trusted_ca_bundle_test.go (1)
236-238: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd failure messages to newly added Gomega assertions. Both sites add new
Expect/g.Expectassertions without a descriptive failure message, unlike neighboring assertions in the same PR (e.g. the restoration check a few lines below in the same test) that do include one — this is explicitly called out for**/*_test.gofiles.
test/e2e/trusted_ca_bundle_test.go#L236-L238: add a message tog.Expect(cm.Labels).To(HaveKeyWithValue(...)), e.g."ConfigMap %s should have the watch label after ExternalSecretsConfig is Ready".test/e2e/e2e_test.go#L2012-L2014: add messages toExpect(createVaultCAConfigMap(...)).To(Succeed())andExpect(createSampleCAConfigMap(...)).To(Succeed()), e.g."failed to create Vault CA ConfigMap"/"failed to create sample CA ConfigMap".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/trusted_ca_bundle_test.go` around lines 236 - 238, Add descriptive failure messages to all newly added Gomega assertions: update the ConfigMap label assertion near the ExternalSecretsConfig readiness check in test/e2e/trusted_ca_bundle_test.go (lines 236-238), and add distinct creation-failure messages to the createVaultCAConfigMap and createSampleCAConfigMap assertions in test/e2e/e2e_test.go (lines 2012-2014).Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/e2e/e2e_test.go`:
- Around line 164-167: Remove the suite-level ensureCertManagerOperatorReady
call from the top-level Ordered Describe BeforeAll, and invoke it in the “Vault
Secret Manager” Context’s own BeforeAll near its existing setup. Keep
cert-manager installation scoped to Vault tests, and add the appropriate
MicroShift skip or guard alongside the Context’s existing Skipped:Disconnected
handling.
In `@test/e2e/README.md`:
- Line 155: Move the “Custom Network Policy Naming” paragraph from beneath
trusted_ca_bundle_test.go to the section containing the NetworkPolicy entry for
e2e_test.go. Preserve the paragraph text unchanged and keep it associated with
the NetworkPolicy spec documentation.
- Around line 87-91: The executable default e2e filter must match the documented
exclusion of Vault. Update the default filter in the Makefile target governing
make test-e2e to exclude both Bitwarden and Vault, preserving the existing
behavior for other suites and avoiding changes to the README unless Vault is
intentionally meant to run by default.
In `@test/e2e/testdata/vault/vault.yaml`:
- Around line 51-52: Update the Deployment pod security configuration in
vault.yaml to explicitly set runAsNonRoot and readOnlyRootFilesystem, retain
capability dropping and allowPrivilegeEscalation: false, and disable
service-account token automount unless required. Ensure the /vault/data volume
remains writable while the container root filesystem is read-only.
---
Nitpick comments:
In `@test/e2e/cert_manager_helpers_test.go`:
- Around line 109-141: Update waitForCertManagerOperandPods to use the
Kubernetes structured not-found check k8serrors.IsNotFound(err) instead of
matching "not found" in err.Error(), while preserving the existing retry
behavior for not-found errors and propagation of all other errors.
In `@test/e2e/e2e_test.go`:
- Around line 2759-2816: Wrap the existing ConfigMap Get, Data mutation, and
Update flow in both createVaultCAConfigMap and createSampleCAConfigMap with
retry.RetryOnConflict, re-fetching the ConfigMap on each retry and returning
non-conflict errors immediately. Preserve the existing create-on-NotFound
behavior and ensure the retry callback propagates the final update error.
In `@test/e2e/trusted_ca_bundle_test.go`:
- Around line 236-238: Add descriptive failure messages to all newly added
Gomega assertions: update the ConfigMap label assertion near the
ExternalSecretsConfig readiness check in test/e2e/trusted_ca_bundle_test.go
(lines 236-238), and add distinct creation-failure messages to the
createVaultCAConfigMap and createSampleCAConfigMap assertions in
test/e2e/e2e_test.go (lines 2012-2014).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 30b54f36-5d8e-478d-9d6f-0961fa177082
📒 Files selected for processing (20)
Makefiletest/e2e/README.mdtest/e2e/cert_manager_helpers_test.gotest/e2e/e2e_test.gotest/e2e/testdata/cert-manager/operator.yamltest/e2e/testdata/vault/ca_certificate.yamltest/e2e/testdata/vault/ca_issuer.yamltest/e2e/testdata/vault/certificate.yamltest/e2e/testdata/vault/external_secret.yamltest/e2e/testdata/vault/issuer.yamltest/e2e/testdata/vault/push_secret.yamltest/e2e/testdata/vault/push_source_secret.yamltest/e2e/testdata/vault/templating_external_secret.yamltest/e2e/testdata/vault/templating_k8s_backend.yamltest/e2e/testdata/vault/templating_push_secret.yamltest/e2e/testdata/vault/templating_source_secrets.yamltest/e2e/testdata/vault/vault.yamltest/e2e/trusted_ca_bundle_test.gotest/utils/conditions.gotest/utils/dynamic_resources.go
There was a problem hiding this comment.
🧹 Nitpick comments (3)
test/e2e/e2e_test.go (3)
2012-2046: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd failure messages to the bare
Expect(...).To(Succeed())assertions.Lines 2013, 2014, 2027, 2030, 2040 and 2043 assert success without a message. The helper errors carry context, but a message states the intent of each step directly in the failure output. Example:
.To(Succeed(), "SecretStore %s should report Ready=False with reason %s", secretStoreResourceName, invalidProviderConfigReason).As per coding guidelines: "Flag Ginkgo test assertions that lack meaningful failure messages."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e_test.go` around lines 2012 - 2046, Add meaningful failure messages to each bare Expect(...).To(Succeed()) assertion in this test flow, including createVaultCAConfigMap, createSampleCAConfigMap, both loader operations, setTrustedCABundle calls, and the readiness waits. Use messages describing the intended operation and relevant resource or condition identifiers, while preserving the existing assertions and cleanup behavior.Source: Coding guidelines
2682-2722: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the error-handling style of
ensureVaultNamespaceconsistent, and addGinkgoHelper().The function returns
errorfor the Get and Create paths, but it usesEventually(...).Should(...)in the terminating-namespace path. A failure in that path aborts the spec through Gomega instead of returning an error to the caller.applyVaultcalls this function and propagates its error, so the two failure modes behave differently.Also add
GinkgoHelper()at the top so Gomega reports the caller line, asclearTrustedCABundlealready does at line 2824.♻️ Proposed change
func ensureVaultNamespace(ctx context.Context, clientset *kubernetes.Clientset) error { + GinkgoHelper() By(fmt.Sprintf("Ensuring namespace %s exists", vaultNamespace))Alternatively, replace the two
Eventuallyblocks withwait.PollUntilContextTimeoutand return the resulting error, so the helper reports every failure through its return value.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e_test.go` around lines 2682 - 2722, Add GinkgoHelper() at the start of ensureVaultNamespace, and replace both Eventually(...).Should(...) blocks in the terminating-namespace branch with context-aware polling that returns errors. Ensure timeout or polling failures, including namespace deletion and recreation failures, propagate through ensureVaultNamespace to applyVault instead of aborting via Gomega.
1978-1978: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider splitting this spec into two
Itblocks.The spec asserts two behaviors:
trustedCABundlevalidation (failure with the sample CA, recovery with the Vault CA) and secret synchronization (PushSecret, ExternalSecret, target Secret content). The Context isOrdered, so a secondItcan reuse the state established by the first. A split gives a precise failure signal when only one behavior breaks.As per coding guidelines: "Review Ginkgo test code for single responsibility: each test (It block) should test one specific behavior."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e_test.go` at line 1978, Split the spec into two ordered It blocks: keep the non-matching and Vault CA trustedCABundle validation/recovery assertions together in the first, and move PushSecret, ExternalSecret, and target Secret synchronization/content assertions into the second. Preserve the existing Ordered Context state so the second test reuses the successful Vault CA setup.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/e2e/e2e_test.go`:
- Around line 2012-2046: Add meaningful failure messages to each bare
Expect(...).To(Succeed()) assertion in this test flow, including
createVaultCAConfigMap, createSampleCAConfigMap, both loader operations,
setTrustedCABundle calls, and the readiness waits. Use messages describing the
intended operation and relevant resource or condition identifiers, while
preserving the existing assertions and cleanup behavior.
- Around line 2682-2722: Add GinkgoHelper() at the start of
ensureVaultNamespace, and replace both Eventually(...).Should(...) blocks in the
terminating-namespace branch with context-aware polling that returns errors.
Ensure timeout or polling failures, including namespace deletion and recreation
failures, propagate through ensureVaultNamespace to applyVault instead of
aborting via Gomega.
- Line 1978: Split the spec into two ordered It blocks: keep the non-matching
and Vault CA trustedCABundle validation/recovery assertions together in the
first, and move PushSecret, ExternalSecret, and target Secret
synchronization/content assertions into the second. Preserve the existing
Ordered Context state so the second test reuses the successful Vault CA setup.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: aefb2d26-aee3-4a85-abd1-cfdae0712a50
📒 Files selected for processing (20)
Makefiletest/e2e/README.mdtest/e2e/cert_manager_helpers_test.gotest/e2e/e2e_test.gotest/e2e/testdata/cert-manager/operator.yamltest/e2e/testdata/vault/ca_certificate.yamltest/e2e/testdata/vault/ca_issuer.yamltest/e2e/testdata/vault/certificate.yamltest/e2e/testdata/vault/external_secret.yamltest/e2e/testdata/vault/issuer.yamltest/e2e/testdata/vault/push_secret.yamltest/e2e/testdata/vault/push_source_secret.yamltest/e2e/testdata/vault/templating_external_secret.yamltest/e2e/testdata/vault/templating_k8s_backend.yamltest/e2e/testdata/vault/templating_push_secret.yamltest/e2e/testdata/vault/templating_source_secrets.yamltest/e2e/testdata/vault/vault.yamltest/e2e/trusted_ca_bundle_test.gotest/utils/conditions.gotest/utils/dynamic_resources.go
🚧 Files skipped from review as they are similar to previous changes (18)
- Makefile
- test/e2e/testdata/vault/issuer.yaml
- test/e2e/testdata/vault/external_secret.yaml
- test/e2e/testdata/vault/certificate.yaml
- test/e2e/testdata/vault/push_secret.yaml
- test/e2e/testdata/vault/templating_push_secret.yaml
- test/utils/dynamic_resources.go
- test/e2e/testdata/vault/templating_external_secret.yaml
- test/e2e/testdata/vault/push_source_secret.yaml
- test/e2e/trusted_ca_bundle_test.go
- test/e2e/testdata/vault/vault.yaml
- test/e2e/testdata/vault/templating_k8s_backend.yaml
- test/e2e/testdata/vault/ca_issuer.yaml
- test/e2e/README.md
- test/e2e/testdata/vault/ca_certificate.yaml
- test/e2e/testdata/cert-manager/operator.yaml
- test/e2e/cert_manager_helpers_test.go
- test/utils/conditions.go
…templating Signed-off-by: Bharath B <bhb@redhat.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/e2e/e2e_test.go (1)
1978-1986: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider splitting this spec by behavior.
This
Itasserts four behaviors: trustedCABundle rejection, trustedCABundle recovery, PushSecret synchronization, and ExternalSecret synchronization. A failure in the later stages does not identify which behavior broke. TheContextisOrdered, so you can move the PushSecret and ExternalSecret stages into separateItblocks and keep the CA switch in the first block.Also,
externalsecretsConfigFilethroughtargetSecretKeyare never reassigned. Declare them withconstto match the adjacent templating spec.As per coding guidelines: "Review Ginkgo test code for single responsibility: each test (It block) should test one specific behavior. Flag tests that assert multiple unrelated behaviors".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/e2e/e2e_test.go` around lines 1978 - 1986, Split the ordered spec around its trustedCABundle rejection/recovery, PushSecret synchronization, and ExternalSecret synchronization behaviors into separate It blocks, keeping the Vault CA switch in the first block and preserving shared ordered-state setup as needed. In the spec’s local declarations, change externalsecretsConfigFile, vaultSecretStoreFile, vaultExternalSecretFile, secretStoreResourceName, externalSecretResourceName, and targetSecretKey from var entries to const declarations.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/e2e/e2e_test.go`:
- Around line 2227-2240: Add meaningful failure messages to the assertions
inside the Eventually callback: identify mergedSecretName for the Secrets Get
and secret type checks, and identify the expected registry host for each
parsed.Auths HaveKey assertion. Preserve the existing validation behavior and
the current missing-key message.
---
Nitpick comments:
In `@test/e2e/e2e_test.go`:
- Around line 1978-1986: Split the ordered spec around its trustedCABundle
rejection/recovery, PushSecret synchronization, and ExternalSecret
synchronization behaviors into separate It blocks, keeping the Vault CA switch
in the first block and preserving shared ordered-state setup as needed. In the
spec’s local declarations, change externalsecretsConfigFile,
vaultSecretStoreFile, vaultExternalSecretFile, secretStoreResourceName,
externalSecretResourceName, and targetSecretKey from var entries to const
declarations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 2d4c34a3-f765-4005-82b3-23ee147cf59a
📒 Files selected for processing (20)
Makefiletest/e2e/README.mdtest/e2e/cert_manager_helpers_test.gotest/e2e/e2e_test.gotest/e2e/testdata/cert-manager/operator.yamltest/e2e/testdata/vault/ca_certificate.yamltest/e2e/testdata/vault/ca_issuer.yamltest/e2e/testdata/vault/certificate.yamltest/e2e/testdata/vault/external_secret.yamltest/e2e/testdata/vault/issuer.yamltest/e2e/testdata/vault/push_secret.yamltest/e2e/testdata/vault/push_source_secret.yamltest/e2e/testdata/vault/templating_external_secret.yamltest/e2e/testdata/vault/templating_k8s_backend.yamltest/e2e/testdata/vault/templating_push_secret.yamltest/e2e/testdata/vault/templating_source_secrets.yamltest/e2e/testdata/vault/vault.yamltest/e2e/trusted_ca_bundle_test.gotest/utils/conditions.gotest/utils/dynamic_resources.go
🚧 Files skipped from review as they are similar to previous changes (18)
- Makefile
- test/e2e/testdata/vault/push_source_secret.yaml
- test/utils/dynamic_resources.go
- test/e2e/testdata/vault/push_secret.yaml
- test/e2e/testdata/vault/external_secret.yaml
- test/e2e/testdata/vault/issuer.yaml
- test/e2e/testdata/vault/templating_push_secret.yaml
- test/e2e/testdata/vault/ca_issuer.yaml
- test/e2e/testdata/vault/ca_certificate.yaml
- test/e2e/testdata/vault/templating_external_secret.yaml
- test/e2e/testdata/vault/templating_k8s_backend.yaml
- test/e2e/testdata/cert-manager/operator.yaml
- test/utils/conditions.go
- test/e2e/README.md
- test/e2e/trusted_ca_bundle_test.go
- test/e2e/testdata/vault/certificate.yaml
- test/e2e/testdata/vault/vault.yaml
- test/e2e/cert_manager_helpers_test.go
| Eventually(func(g Gomega) { | ||
| secret, err := clientset.CoreV1().Secrets(vaultNamespace).Get(ctx, mergedSecretName, metav1.GetOptions{}) | ||
| g.Expect(err).NotTo(HaveOccurred()) | ||
| g.Expect(secret.Type).To(Equal(corev1.SecretTypeDockerConfigJson)) | ||
|
|
||
| raw, ok := secret.Data[corev1.DockerConfigJsonKey] | ||
| g.Expect(ok).To(BeTrue(), "merged secret missing %s", corev1.DockerConfigJsonKey) | ||
|
|
||
| var parsed struct { | ||
| Auths map[string]json.RawMessage `json:"auths"` | ||
| } | ||
| g.Expect(json.Unmarshal(raw, &parsed)).To(Succeed()) | ||
| g.Expect(parsed.Auths).To(HaveKey(baselineRegistryHost)) | ||
| g.Expect(parsed.Auths).To(HaveKey(vaultRegistryHost)) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add failure messages to the merge assertions.
The Get error check, the secret type check, and the two HaveKey checks report no context. When the merge template is wrong, the failure output does not name the secret or the missing registry host.
As per coding guidelines: "Flag Ginkgo test assertions that lack meaningful failure messages."
💚 Proposed fix to add assertion messages
secret, err := clientset.CoreV1().Secrets(vaultNamespace).Get(ctx, mergedSecretName, metav1.GetOptions{})
- g.Expect(err).NotTo(HaveOccurred())
- g.Expect(secret.Type).To(Equal(corev1.SecretTypeDockerConfigJson))
+ g.Expect(err).NotTo(HaveOccurred(), "failed to get merged secret %s/%s", vaultNamespace, mergedSecretName)
+ g.Expect(secret.Type).To(Equal(corev1.SecretTypeDockerConfigJson),
+ "merged secret %s should have type %s", mergedSecretName, corev1.SecretTypeDockerConfigJson)
raw, ok := secret.Data[corev1.DockerConfigJsonKey]
g.Expect(ok).To(BeTrue(), "merged secret missing %s", corev1.DockerConfigJsonKey)
var parsed struct {
Auths map[string]json.RawMessage `json:"auths"`
}
- g.Expect(json.Unmarshal(raw, &parsed)).To(Succeed())
- g.Expect(parsed.Auths).To(HaveKey(baselineRegistryHost))
- g.Expect(parsed.Auths).To(HaveKey(vaultRegistryHost))
+ g.Expect(json.Unmarshal(raw, &parsed)).To(Succeed(),
+ "failed to parse %s from merged secret %s", corev1.DockerConfigJsonKey, mergedSecretName)
+ g.Expect(parsed.Auths).To(HaveKey(baselineRegistryHost),
+ "merged auths should contain the Kubernetes backend host %s", baselineRegistryHost)
+ g.Expect(parsed.Auths).To(HaveKey(vaultRegistryHost),
+ "merged auths should contain the Vault backend host %s", vaultRegistryHost)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Eventually(func(g Gomega) { | |
| secret, err := clientset.CoreV1().Secrets(vaultNamespace).Get(ctx, mergedSecretName, metav1.GetOptions{}) | |
| g.Expect(err).NotTo(HaveOccurred()) | |
| g.Expect(secret.Type).To(Equal(corev1.SecretTypeDockerConfigJson)) | |
| raw, ok := secret.Data[corev1.DockerConfigJsonKey] | |
| g.Expect(ok).To(BeTrue(), "merged secret missing %s", corev1.DockerConfigJsonKey) | |
| var parsed struct { | |
| Auths map[string]json.RawMessage `json:"auths"` | |
| } | |
| g.Expect(json.Unmarshal(raw, &parsed)).To(Succeed()) | |
| g.Expect(parsed.Auths).To(HaveKey(baselineRegistryHost)) | |
| g.Expect(parsed.Auths).To(HaveKey(vaultRegistryHost)) | |
| Eventually(func(g Gomega) { | |
| secret, err := clientset.CoreV1().Secrets(vaultNamespace).Get(ctx, mergedSecretName, metav1.GetOptions{}) | |
| g.Expect(err).NotTo(HaveOccurred(), "failed to get merged secret %s/%s", vaultNamespace, mergedSecretName) | |
| g.Expect(secret.Type).To(Equal(corev1.SecretTypeDockerConfigJson), | |
| "merged secret %s should have type %s", mergedSecretName, corev1.SecretTypeDockerConfigJson) | |
| raw, ok := secret.Data[corev1.DockerConfigJsonKey] | |
| g.Expect(ok).To(BeTrue(), "merged secret missing %s", corev1.DockerConfigJsonKey) | |
| var parsed struct { | |
| Auths map[string]json.RawMessage `json:"auths"` | |
| } | |
| g.Expect(json.Unmarshal(raw, &parsed)).To(Succeed(), | |
| "failed to parse %s from merged secret %s", corev1.DockerConfigJsonKey, mergedSecretName) | |
| g.Expect(parsed.Auths).To(HaveKey(baselineRegistryHost), | |
| "merged auths should contain the Kubernetes backend host %s", baselineRegistryHost) | |
| g.Expect(parsed.Auths).To(HaveKey(vaultRegistryHost), | |
| "merged auths should contain the Vault backend host %s", vaultRegistryHost) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/e2e/e2e_test.go` around lines 2227 - 2240, Add meaningful failure
messages to the assertions inside the Eventually callback: identify
mergedSecretName for the Secrets Get and secret type checks, and identify the
expected registry host for each parsed.Auths HaveKey assertion. Preserve the
existing validation behavior and the current missing-key message.
Source: Coding guidelines
|
@bharath-b-rh: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
BeforeAll) with a real CA→server cert chain fortrustedCABundlevalidation.InvalidProviderConfig→Ready, PushSecret/ExternalSecret sync, and ExternalSecret templating merge (Kubernetes + Vault dockerconfig).Test plan
make test-e2e E2E_GINKGO_LABEL_FILTER="!(Feature: containsAny {Proxy, Upgrade})"Summary by CodeRabbit
New Features
Documentation
Tests